<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/jquery-weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/index.css" />
		<title>指数</title>
		<script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/baseConfig.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/city-picker.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<!--<div id="header">
			<div class="header-title" style="position: fixed;top: 0;">
				<!--<img src="img/left.png" class="left" />-->
				<!--<span>供应链</span>-->
			<!--</div>
		</div>-->

		<div class="content-body" style="margin-top: 0;">
			<!--<div class="identity-type">
				<span>指数</span>
			</div>-->
			<div class="input-warp">
				<div class="input-left">
					<input type="text" id="city-picker" value="" readonly />
					<img src="../../img/right.png" />
				</div>
				<div class="input-right">
					<input type="text" id="my-input" readonly />
					<img src="../../img/right.png" />
				</div>
			</div>
			<ul class="ul_warp">
				<li>供应市场</li>
				<li>物料名称</li>
				<li>到厂价格</li>
				<li>自提价格</li>
			</ul>
			<ol class="ol_warp">
				<!--<li>
					<span>哈尔滨</span>
					<span>冰箱压缩机</span>
					<span>25000</span>
					<span>50</span>
				</li>
				-->
			</ol>
		</div>
	</body>
	<script type="text/javascript">
		$(document).ready(function() {
//			document.title = "供应链"
//			location.href = "html/mine/mine.html"
			getContent(baseConfig.getNowFormatDate())
//			$("#city-picker").val('天津')
			$("#my-input").datetimePicker({
				times: function() {},
				value: "" + baseConfig.getNowFormatDate() + " " + " ",
				onClose: function() {
					if(!$("#city-picker").attr("cityId")){
						getContent($("#my-input").val())
					}else{
						getContent($("#my-input").val(),$("#city-picker").attr("cityId"))
					}
						
				},
			})
		 
			function getContent(date1,city){
				$.ajax({
					type: "get",
					url: baseConfig.localHttp + "weChatApi/fgclient/getIndexList",
					async: false,
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data:{
						date1:date1,
						city:city
					},
					success: function(data) {
						$(".ol_warp").empty()
						var indexList = data.content.indexList
						var li="";
						for(var i=0;i<indexList.length;i++){
							li += "<li><span>"+indexList[i].cityName+"</span><span>"+indexList[i].materialName+"</span><span>"+indexList[i].toFactoryPrice+"</span><span>"+indexList[i].materialId+"</span></li>"
						}
						$(".ol_warp").append(li)
						
						var Data = data.content.areaList
						var temp = [];
						for(var i=0;i<Data.length;i++){
							temp.push(Data[i].name)
						}
						if(data.code == 100) {
							$("#city-picker").picker({
								title: "选择地区",
								cols: [{
									textAlign: 'center',
									values:temp
								}],
								onClose: function(e) {
									var index = e.cols[0].activeIndex
									var id = Data[index].id
									$("#city-picker").attr("cityId",id)
									getContent( $("#my-input").val(),id)
								}
							});
						} else {
							$.toptip(data.content, 1500, 'error');
						}
					},
					error: function() {
//						$.toptip(data.content, 1500, 'error');
					}
				}) 
			}
			
		})
	</script>

</html>